//
//  FuelLogAppDelegate.h
//  FuelLog
//
//  Created by Pure Mass Communications on 9/1/08.
//  Copyright 2008 . All rights reserved.
//
//  Placed under GPL v2 with the kind permission of Pure Mass Communications
//
//  Modified to make compile under SDK 3.1 by Olaf Greck in May 2010
//
//
//  This program is free software; you can redistribute it and/or
//  modify it under the terms of the GNU General Public License
//  as published by the Free Software Foundation; either version 2
//  of the License, or (at your option) any later version.

//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.

//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

#import <UIKit/UIKit.h>
#import <sqlite3.h>
#import "Car.h"
#import "Gas.h"
#import "Pref.h"

@class FuelLogViewController;

@interface FuelLogAppDelegate : NSObject <UIApplicationDelegate> {
	IBOutlet UIWindow *window;
	IBOutlet FuelLogViewController *viewController;
	
	NSMutableArray *cars;
	NSMutableArray *pumps;
	NSMutableArray *sections;
	Car *currentCar;
	
	sqlite3 *database;
	
	NSString *username;
	NSString *password;
	NSDateFormatter *defaultDateFormatter;
	NSDateFormatter *googDateFormatter;
}

@property (nonatomic, retain) UIWindow *window;
@property (nonatomic, retain) FuelLogViewController *viewController;

@property (nonatomic, retain) NSMutableArray *cars;
@property (nonatomic, retain) NSMutableArray *pumps;
@property (nonatomic, assign) Car *currentCar;
@property (nonatomic, retain) NSMutableArray *sections;

@property (nonatomic, copy) NSString *username;
@property (nonatomic, copy) NSString *password;
@property (nonatomic, assign) NSDateFormatter *defaultDateFormatter;
@property (nonatomic, assign) NSDateFormatter *googDateFormatter;

+ (Pref *)pref;
+ (NSDate *)getNoonUTC:(NSDate *)date;
+ (NSDate *)getMonthsBefore:(NSDate *)date months:(int) months;
+ (float) scanFloat:(NSString *)aString;
- (void)addCar:(Car *)car;
- (BOOL)hasCar:(NSString *)name;
- (Car *)chooseCar:(Car *)car;
- (Car *)chooseCarByKey:(int)pk;
- (Car *)chooseCarByIndex:(int)idx;
- (void)removeCar:(Car *)car;
- (void)addGas:(Gas *)gas;
- (void)addGasIfNeeded:(Gas *)gas previous:(Gas *)prev next:(Gas *)next;
- (void)removeGas:(Gas *)gas;
- (Gas *)findPreviousGasEntry:(NSDate *)date odometer:(float)odometer;
- (Gas *)findNextGasEntry:(NSDate *)date odometer:(float)odometer;
- (float)gasEconomy:(int)pk odometer:(float)odometer fuel:(float)volume;

@end

